$(function(){
	$("#exportCoupon").click(function(){
		var url = "${interface_url}/coupon/checkExportCount.do";
		var exportUrl = "${interface_url}/coupon/exportRecordExcel.do";
		var startTime = $("#timepickerStart1").val();
		var endTime = $("#timepickerEnd1").val();
		if(startTime == "" || endTime == ""){
			alert("请选择时间");
			return;
		}
		 $.ajax({
		        type: "post",
		        url: url,
		        data : {startTime : startTime,endTime : endTime},
		        dataType: "json",
		        error: function(){
		        	alert("系统繁忙,请稍后重试");
		        },
		        success: function(responseData){
		        	if(responseData != null && responseData.retFlag == "1"){
		        		if(responseData.data.sysMsg == "0"){
		        			alert("导出数据不能为空,请修改查询时间");
		        		}else{
		        			if(window.confirm("确定导出"+responseData.data.sysMsg+"条？")){
		                        window.location.href = exportUrl + "?startTime="+startTime+"&endTime="+endTime;
		                     }else{
		                        return;
		                     }
		        		}
		        	}else if(responseData.retFlag == "0"){
		        		alert("导出失败:"+responseData.errorMessage);
		        	}else{
		        		alert("导出失败");
		        	}
		        }
		    });
	});
	
	$("#exportCharge").click(function(){
		var url = "${interface_url}/precharge/checkExportCount.do";
		var exportUrl = "${interface_url}/precharge/exportRecordExcel.do";
		var startTime = $("#timepickerStart1").val();
		var endTime = $("#timepickerEnd1").val();
		if(startTime == "" || endTime == ""){
			alert("请选择时间");
			return;
		}
		 $.ajax({
		        type: "post",
		        url: url,
		        data : {startTime : startTime,endTime : endTime},
		        dataType: "json",
		        error: function(){
		        	alert("系统繁忙,请稍后重试");
		        },
		        success: function(responseData){
		        	if(responseData != null && responseData.retFlag == "1"){
		        		if(responseData.data.sysMsg == "0"){
		        			alert("导出数据不能为空,请修改查询时间");
		        		}else{
		        			if(window.confirm("确定导出"+responseData.data.sysMsg+"条？")){
		                        window.location.href = exportUrl + "?startTime="+startTime+"&endTime="+endTime;
		                     }else{
		                        return;
		                     }
		        		}
		        	}else if(responseData.retFlag == "0"){
		        		alert("导出失败:"+responseData.errorMessage);
		        	}else{
		        		alert("导出失败");
		        	}
		        }
		    });
	});
	
	// 导出异业券
	$("#exportHorizProCoupon").click(function(){
		var url = "${interface_url}/coupon/checkValidHorizCouponCount.do";
		var exportUrl = "${interface_url}/coupon/exportValidHorizCoupon.do";
		var startTime = $("#timepickerStart1").val();
		var endTime = $("#timepickerEnd1").val();
		if(startTime == "" || endTime == ""){
			alert("请选择时间");
			return;
		}
		 $.ajax({
		        type: "post",
		        url: url,
		        data : {startTime : startTime,endTime : endTime},
		        dataType: "json",
		        error: function(){
		        	alert("系统繁忙,请稍后重试");
		        },
		        success: function(responseData){
		        	if(responseData != null && responseData.retFlag == "1"){
	        			if(window.confirm("确定导出记录？")){
	                        window.location.href = exportUrl + "?startTime="+startTime+"&endTime="+endTime;
	                     }else{
	                        return;
	                     }
		        	}else if(responseData.retFlag == "0"){
		        		alert("导出失败:"+responseData.errorMessage);
		        	}else{
		        		alert("导出失败");
		        	}
		        }
		    });
	});
});